<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>${r'${sysName}'}</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="format-detection" content="telephone=no">
	<link rel="stylesheet" href="${r'${resRoot}'}/layui/css/layui.css" media="all" />
	<link rel="stylesheet" href="${r'${resRoot}'}/css/main.css" media="all" />
	<link rel="stylesheet" href="${r'${resRoot}'}/layui/admin/admin.css" media="all" />
</head>
<body class="childrenBody">
	<div class="layui-fluid">   
          <div class="layui-card">
	<div class="layui-form layui-card-header layuiadmin-card-header-auto">
	<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
		<legend>信息 -导入</legend>
	</fieldset>
	<form id="searchForm" class="layui-form layui-form-pane" method="post" action=""  >
		<div class="layui-form-item">
	  	<div class="layui-input-block">
		  <div class="layui-upload">
			  <button type="button" class="layui-btn layui-btn-normal" name="fileField" id="test8" lay-type="file">选择文件</button>
			  <button type="button" class="layui-btn" id="test9" onclick="showBg();" >开始上传</button>
			  <a class="layui-btn layui-btn-normal" href="${r'${base}'}/sys/${table.entityPath?substring(0, table.entityPath?length - 3)}/importTemplate" download="data">数据导入表格下载</a>
			  <button type="button" class="layui-btn layui-btn-primary"
					onclick="backList();">返回</button>
			</div>
			</div>
	  </div>
		</form>
	</div>
	</div></div>
	${r'<#include "/page/footer.html">'}
	<script>
	
	function backList() {
		layer.closeAll("iframe");
	    //刷新父页面
	    parent.location.reload();
	}
	function showBg() {
		var index = layer.load(0, {
			  shade: [0.5,'#fff'] //0.1透明度的白色背景
			});
	}
	function closeBg() {
		layer.closeAll(); 
	}
	layui.use(['form', 'layedit', 'laydate', 'upload'], function(){
		var form = layui.form
		  ,layer = layui.layer
		  ,layedit = layui.layedit
		  ,upload = layui.upload
		  ,laydate = layui.laydate;
		// 选完文件后不自动上传
		  upload.render({
		    elem: '#test8'
		    ,url: '${r'${base}'}/sys/${table.entityPath?substring(0, table.entityPath?length - 3)}/importFile'
		    ,accept: 'file' //普通文件
		    ,exts:'xls|xlsx'
		    ,auto: false
		    ,bindAction: '#test9'
	    	,before: function(obj){
		    	  // this.data.param = JSON.stringify({"villageId":$("#villageId").val()}) // 参数传入
		      }
		    ,done: function(res){
		    	layer.closeAll('loading'); //关闭loading
		    	console.log(res);
		    	if(res != "") {
		    		var obj = res; //eval('(' + res + ')');
		    		closeBg();
		    		if(obj.code==1) {
		    			layer.alert("导入sheet" + obj.data.successNum + "个，失败" + obj.data.failureNum + "条(数据：" + obj.data.failureMsg + ")");
		    		}
				}
		    	console.log(res);
		    }
		  ,error: function(index, upload){
			    layer.closeAll('loading'); //关闭loading
			  }
		  });
		});
</script>
</body>
</html>